<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
        <script type="text/javascript" src="lib/html5shiv.js"></script>
        <script type="text/javascript" src="lib/respond.min.js"></script>
        <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="./../lib/layui/css/layui.css">
    <!--[if IE 6]>
        <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
    <title>黑名单列表</title>
</head>

<body>
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span
            class="c-gray en">&gt;</span> 黑名单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
            href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <div class="cl pd-5 bg-1 bk-gray mt-20" style="border:0;background:none"> <span class="l"></span> </div>
        <table class="layui-hide" id="blackList" lay-filter="blacklist"></table>
    </div>
    <input type="" name="details_id" id="details_id" value="" style="display:none;" />
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="./../static/js/common.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="./../lib/layui/layui.js"></script>
    <!--/_footer 作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/html" id="operation">
        	<a  title="移除黑名单" lay-event="del" class=""><i class="Hui-iconfont">&#xe644;</i></a>
    </script>
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
          <button class="layui-btn layui-btn-sm" lay-event="allDel"> 一键清除</button>
        </div>
      </script>
    <script type="text/javascript">
        layui.use('table', function () {
            var table = layui.table
                , form = layui.form;
            table.render({
                elem: '#blackList',
                toolbar: '#toolbar',
                defaultToolbar: [],
                url: admin_url + '/kvmBlackList/blackList',
                cellMinWidth: 80,
                id: 'reload2',
                request: {
                    pageName: 'page',
                    limitName: 'size'
                },
                // 额外的数据参数
                where: {
                    tokenUserId: userId,
                    token: token
                },
                method: 'post',
                // 回调
                done: function (res, curr, count) {
                    console.log(res)
                    var data = res.data;
                },
                paresData: function (res) {
                    return {
                        'data': res.data
                    }
                },
                response: {
                    statusCode: 200
                },
                cols: [[
                    { checkbox: true, align: 'center' },
                    { field: 'id', title: 'ID', align: 'center', width: 80 }
                    , { field: 'userName', title: '用户名', align: 'center' }
                    , { field: 'createTime', title: '加入黑名单时间', align: 'center' }
                    , { toolbar: '#operation', title: '操作', align: 'center' }
                ]],
                page: true
            })
            // 监听行操作栏事件。。可直接传值..
            table.on('tool(blacklist)', function (obj) {
                var data = obj.data;
                console.log(obj.data.ipMobile)
                if (obj.event === 'del') {
                    layer.confirm('确认要移除黑名单?', function (index) {
                        console.log(index);
                        // 调用单个移除黑名单接口
                        $.ajax({
                            type: "post",
                            xhrFields: { withCredentials: true },
                            url: admin_url + '/kvmBlackList/delBlack',
                            data: { tokenUserId: userId, token: token, id: data.id },
                            success: function (data) {
                                console.log(data)
                                if (data.code == 200) {
                                    layer.msg('删除成功', {
                                        time: 1500,
                                        end: function () {
                                            $(".layui-laypage-btn").click();
                                        }
                                    })
                                } else {
                                    layer.msg('删除失败，请重试', {
                                        time: 1500
                                    })
                                }
                            }, error: function () {
                                console.log('网络波动')
                            }
                        })
                    })
                }
            })
            table.on('toolbar(blacklist)', function (obj) {
             
                switch (obj.event) {
                    case 'allDel':
                    layer.confirm('确认一键清除黑名单', { title: '一键清除' }, function () {
                $.ajax({
                    type: "post",
                    xhrFields: { withCredentials: true },
                    url: admin_url + '/kvmBlackList/delAllBlack',
                    data: { tokenUserId: userId, token: token },
                    success: function (data) {
                        console.log(data)
                        if (data.code == 200) {
                            layer.msg('清除成功', {
                                time: 1500,
                                end: function () {
                                    location.replace(location.href)
                                }
                            })
                        } else {
                            layer.msg('清除失败', {
                                time: 1500
                            })
                        }
                    }
                })
            })

                }
            });
        })
    </script>
</body>

</html>